﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tools.Framework
{
    public class IOHelper
    {
        /// <summary>
        /// 临时文件存储
        /// </summary>
        /// <param name="path">存储路径</param>
        /// <param name="content">存储内容</param>
        public static void creatIO(string path, string content)
        {
            if (File.Exists(path))
            {
                //写入
                FileStream fs = new FileStream(path, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                //开始写入
                sw.Write(content);
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
            }
            else
            {
                File.Create(path);
                //写入
                FileStream fs = new FileStream(path, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                //开始写入
                sw.Write(content);
                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                fs.Close();
            }


        }
    }
}
